package com.example.arcapplication.bean;

import com.example.arcapplication.db.DaoSession;
import com.example.arcapplication.db.DataListDao;
import com.example.arcapplication.db.HwListDao;
import com.example.arcapplication.db.InventoryDao;
import com.example.arcapplication.db.StockListDao;

import org.greenrobot.greendao.DaoException;
import org.greenrobot.greendao.annotation.Entity;
import org.greenrobot.greendao.annotation.Generated;
import org.greenrobot.greendao.annotation.Id;
import org.greenrobot.greendao.annotation.ToMany;

import java.util.List;

@Entity
public class Inventory {

    @Id(autoincrement = true)
    private Long id;

    // 单据类型 23=到货单,4455=材料出库,5X=调拨订单
    private String billType;

    // 单据类型名称
    private String billTypeName;

    private Long sid;
    private Long hid;
    private Long did;

    @ToMany(referencedJoinProperty = "sid")
    private List<StockList> stockList;
    @ToMany(referencedJoinProperty = "hid")
    private List<HwList> hwList;
    @ToMany(referencedJoinProperty = "did")
    private List<DataList> dataList;

    // 单据号
    private String djh;

    /** Used to resolve relations */
    @Generated(hash = 2040040024)
    private transient DaoSession daoSession;

    /** Used for active entity operations. */
    @Generated(hash = 433391049)
    private transient InventoryDao myDao;

    @Generated(hash = 418211827)
    public Inventory(Long id, String billType, String billTypeName, Long sid,
            Long hid, Long did, String djh) {
        this.id = id;
        this.billType = billType;
        this.billTypeName = billTypeName;
        this.sid = sid;
        this.hid = hid;
        this.did = did;
        this.djh = djh;
    }

    @Generated(hash = 375708430)
    public Inventory() {
    }

    public Long getId() {
        return this.id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getBillType() {
        return this.billType;
    }

    public void setBillType(String billType) {
        this.billType = billType;
    }

    public String getBillTypeName() {
        return this.billTypeName;
    }

    public void setBillTypeName(String billTypeName) {
        this.billTypeName = billTypeName;
    }

    public Long getSid() {
        return this.sid;
    }

    public void setSid(Long sid) {
        this.sid = sid;
    }

    public Long getHid() {
        return this.hid;
    }

    public void setHid(Long hid) {
        this.hid = hid;
    }

    public Long getDid() {
        return this.did;
    }

    public void setDid(Long did) {
        this.did = did;
    }

    public String getDjh() {
        return this.djh;
    }

    public void setDjh(String djh) {
        this.djh = djh;
    }

    /**
     * To-many relationship, resolved on first access (and after reset).
     * Changes to to-many relations are not persisted, make changes to the target entity.
     */
    @Generated(hash = 431471078)
    public List<StockList> getStockList() {
        if (stockList == null) {
            final DaoSession daoSession = this.daoSession;
            if (daoSession == null) {
                throw new DaoException("Entity is detached from DAO context");
            }
            StockListDao targetDao = daoSession.getStockListDao();
            List<StockList> stockListNew = targetDao._queryInventory_StockList(id);
            synchronized (this) {
                if (stockList == null) {
                    stockList = stockListNew;
                }
            }
        }
        return stockList;
    }

    /** Resets a to-many relationship, making the next get call to query for a fresh result. */
    @Generated(hash = 1408028614)
    public synchronized void resetStockList() {
        stockList = null;
    }

    /**
     * To-many relationship, resolved on first access (and after reset).
     * Changes to to-many relations are not persisted, make changes to the target entity.
     */
    @Generated(hash = 1515913463)
    public List<HwList> getHwList() {
        if (hwList == null) {
            final DaoSession daoSession = this.daoSession;
            if (daoSession == null) {
                throw new DaoException("Entity is detached from DAO context");
            }
            HwListDao targetDao = daoSession.getHwListDao();
            List<HwList> hwListNew = targetDao._queryInventory_HwList(id);
            synchronized (this) {
                if (hwList == null) {
                    hwList = hwListNew;
                }
            }
        }
        return hwList;
    }

    /** Resets a to-many relationship, making the next get call to query for a fresh result. */
    @Generated(hash = 2144107953)
    public synchronized void resetHwList() {
        hwList = null;
    }

    /**
     * To-many relationship, resolved on first access (and after reset).
     * Changes to to-many relations are not persisted, make changes to the target entity.
     */
    @Generated(hash = 1420495488)
    public List<DataList> getDataList() {
        if (dataList == null) {
            final DaoSession daoSession = this.daoSession;
            if (daoSession == null) {
                throw new DaoException("Entity is detached from DAO context");
            }
            DataListDao targetDao = daoSession.getDataListDao();
            List<DataList> dataListNew = targetDao._queryInventory_DataList(id);
            synchronized (this) {
                if (dataList == null) {
                    dataList = dataListNew;
                }
            }
        }
        return dataList;
    }

    /** Resets a to-many relationship, making the next get call to query for a fresh result. */
    @Generated(hash = 774597464)
    public synchronized void resetDataList() {
        dataList = null;
    }

    /**
     * Convenient call for {@link org.greenrobot.greendao.AbstractDao#delete(Object)}.
     * Entity must attached to an entity context.
     */
    @Generated(hash = 128553479)
    public void delete() {
        if (myDao == null) {
            throw new DaoException("Entity is detached from DAO context");
        }
        myDao.delete(this);
    }

    /**
     * Convenient call for {@link org.greenrobot.greendao.AbstractDao#refresh(Object)}.
     * Entity must attached to an entity context.
     */
    @Generated(hash = 1942392019)
    public void refresh() {
        if (myDao == null) {
            throw new DaoException("Entity is detached from DAO context");
        }
        myDao.refresh(this);
    }

    /**
     * Convenient call for {@link org.greenrobot.greendao.AbstractDao#update(Object)}.
     * Entity must attached to an entity context.
     */
    @Generated(hash = 713229351)
    public void update() {
        if (myDao == null) {
            throw new DaoException("Entity is detached from DAO context");
        }
        myDao.update(this);
    }

    /** called by internal mechanisms, do not call yourself. */
    @Generated(hash = 1763418221)
    public void __setDaoSession(DaoSession daoSession) {
        this.daoSession = daoSession;
        myDao = daoSession != null ? daoSession.getInventoryDao() : null;
    }

}
